Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

297
Visualizações
"return self.title</pre>" returns a syntax error django

Please bear with my ineptitude. I'm trying upgrade my skillset from simple python scripts to something closer to resembling a full stack developer. RN I am creating a simple Django todo app and am going through a basic tutorial here. https://www.geeksforgeeks.org/python-todo-webapp-using-django/

Env is setup with the following...

Python==3.8.9

Django==3.2.9

django-crispy-forms==1.13.0

my models.py looks like this:

from django.db import models
from django.utils import timezone


class Todo(models.Model):
    title = models.CharField(max_length=100)
    details = models.TextField()
    date = models.DateTimeField(default=timezone.now)
, if I am correct in assuming this is related to CSS. 

I am not sure where to go from here. Can anyone help me? 
    def __str__(self):
        return self.title</pre>


and my forms.py looks like this

from django import forms
from .models import Todo


class TodoForm(forms.ModelForm):
    class Meta:
        model = Todo
        fields = "__all__"</pre>

When I execute python3 manage.py makemigrations or runserver I get the following error and am clearly unable to figure out why.

  File "/home/ezurel/Coding/AppleTree/AppleTree/urls.py", line 19, in <module>
    from todone import views
  File "/home/ezurel/Coding/AppleTree/todone/views.py", line 7, in <module>
    from .forms import TodoForm
  File "/home/ezurel/Coding/AppleTree/todone/forms.py", line 8
    fields = "__all__"</pre>
                       ^
SyntaxError: invalid syntax

I'm stumped as to the need for the </pre> tag and to why it needs to be there and not as part of the HTML, if I am correct in assuming this is related to CSS.

I am not sure where to go from here. Can anyone help me?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Remove the </pre> tag. This tag was (very) likely used to typeset a code fragment, since code fragments are written between <pre> … </pre>, but it is not valid Python code:

class TodoForm(forms.ModelForm):
    class Meta:
        model = Todo
        fields = "__all__"  # ← no </pre>

and for the model:

class Todo(models.Model):
    title = models.CharField(max_length=100)
    details = models.TextField()
    date = models.DateTimeField(default=timezone.now)
    
    def __str__(self):
        return self.title # ← no </pre>
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda